package com.example.basic.window.popupwindow;

import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.PopupWindow;

public class PopupWindowUtils {


    public void show(View view) {
        PopupWindow mUpdateTipsPopupWindow = new PopupWindow(view,
                LinearLayout.LayoutParams.WRAP_CONTENT,
                LinearLayout.LayoutParams.WRAP_CONTENT);
        mUpdateTipsPopupWindow.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
        mUpdateTipsPopupWindow.setOutsideTouchable(true);
        view.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED);

        int windowHeight = view.getMeasuredHeight();
        int windowWidth = view.getMeasuredWidth();

        Log.d("xcl_debug", "showUpdateTipsPopWindow: windowHeight = " + windowHeight + " windowWidth = " + windowWidth );

//        int pxInt14 = WindowUtil.dpToPxInt(16);
//        int pxInt4 = WindowUtil.dpToPxInt(4);

        mUpdateTipsPopupWindow.setContentView(view);
        mUpdateTipsPopupWindow.showAsDropDown(view,0,0);
//        mUpdateTipsPopupWindow.showAtLocation(view, Gravity.CENTER,0,0);
    }
}
